/**
 * Created by Administrator on 2017/1/3.
 */
class GameSceneBaoChange extends BaseSprite {

    baoText: egret.TextField;
    cardView: CardView;

    constructor() {
        super();
        this.skinName = 'GameSceneBaoChangeSkin';

        this.touchChildren = false;
        this.touchEnabled = false;
    }

    childrenCreated() {
        super.childrenCreated();

        this.horizontalCenter = this.verticalCenter = 0;

        this.cardView = CardView.create(1, 1);
        this.cardView.x = this.width >> 1;
        this.cardView.y = this.height >> 1;
        this.addChild(this.cardView);
    }

    play(pai: any = null) {

        GameSound.play("sound_bao_change");

        this.show();

        this.cardView.changePai(pai);

        this.baoText.scaleX = this.baoText.scaleX = 3;

        let thiz = this;
        egret.Tween.get(this.baoText)
            .to({scaleX: 1, scaleY: 1}, 500)
            .wait(1500)
            .call(function () {
                thiz.hide();
            });
    }

    show() {
        super.show();

        if (!gameManager.layerManager.effectLayer.contains(this)) {
            gameManager.layerManager.effectLayer.addChild(this);
        }
    }

    hide() {
        super.hide();

        if (gameManager.layerManager.effectLayer.contains(this)) {
            gameManager.layerManager.effectLayer.removeChild(this);
        }
    }
}